feat: add log file support and rendering optimisations#14
feat: add log file support and rendering optimisations#14neilmartin83 wants to merge 13 commits intomacadmins:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds QuickLook preview support for log-like files and introduces rendering optimizations to keep previews responsive on large inputs.
Changes:
- Add
.log/.out/.erras a supportedFileFormatwith a heuristic, line-by-line tokenizer. - Add large-input truncation and optimize HTML rendering (
escapeHTML,renderTokens) to reduce allocation overhead. - Register log UTIs / file extensions for the app + preview extension, and add UI + test coverage for the new format.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| Shared/SyntaxHighlighter.swift | Adds log tokenizer; adds truncation + rendering performance changes. |
| PiquePreview/Info.plist | Registers io.macadmins.pique.log and adds log extensions/UTIs to QuickLook supported types. |
| PiquePreview/PreviewProvider.swift | Maps log-like extensions to the “Log” appearance group name. |
| Pique/Info.plist | Declares the log UTI for the main app bundle. |
| Pique/ContentView.swift | Adds “Log” to the supported format badges. |
| Pique/SettingsView.swift | Adds “Log” to appearance override settings. |
| PiqueTests/FileFormatTests.swift | Tests .log/.out/.err mapping + case-insensitivity. |
| PiqueTests/HighlightIntegrationTests.swift | Adds integration tests for log highlighting + truncation behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot apply changes based on the comments in this thread |
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Update log token classes and rendering plus add robust preview truncation. Tests were updated to expect new log-specific CSS classes (logError, logWarn, logInfo, logDebug, logTimestamp). SyntaxHighlighter was refactored to: count lines efficiently, truncate at the last line boundary within the preview limit, append a styled truncation notice, and apply truncation to special-format renderers (mobileconfig/JSON profiles). The token pipeline was unified to renderTokens in the switch, new Token.Kind entries for log categories were added, and the log tokenizer/status-code mapping and color palettes (dark/light) were adjusted accordingly.
There was a problem hiding this comment.
Pull request overview
Adds .log QuickLook preview support and improves rendering performance for large files by introducing truncation and faster HTML/token rendering in the shared highlighter.
Changes:
- Add
.log(.log,.out,.err) file format with heuristic, line-by-line tokenization and new severity/timestamp token kinds + CSS. - Optimize rendering performance (
escapeHTMLsingle-pass,renderTokenspreallocated buffer) and truncate large previews (~500KB) with a truncation notice. - Register log UTIs / extensions in app + QuickLook extension and expose “Log” in UI/settings; add tests for format mapping + log highlighting.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| Shared/SyntaxHighlighter.swift | Adds .log format, log tokenizer + new token kinds/styles, rendering optimizations, and truncation logic/notice. |
| PiquePreview/Info.plist | Declares log UTI and registers it (and related types/extensions) for QuickLook preview support. |
| PiquePreview/PreviewProvider.swift | Maps .log/.out/.err extensions to the “Log” appearance group name. |
| Pique/Info.plist | Declares the log UTI for the main app. |
| Pique/ContentView.swift | Adds a “Log” badge to the supported formats list shown in the app UI. |
| Pique/SettingsView.swift | Adds “Log” to appearance override settings groups. |
| PiqueTests/FileFormatTests.swift | Tests extension-to-FileFormat mapping for log-related extensions (including case-insensitivity). |
| PiqueTests/HighlightIntegrationTests.swift | Adds integration tests for log highlighting and truncation behavior (currently focused on .log). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot apply changes based on the comments in this thread |
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR adds QuickLook preview support for log-like files (.log, .out, .err) with heuristic syntax highlighting, and introduces rendering optimizations intended to improve performance on large inputs (including a preview truncation feature).
Changes:
- Add a
.logfile format with a heuristic, line-by-line tokenizer and dedicated token kinds/styles. - Add UTType/QuickLook registration and format-name mapping for log files across the app and preview extension.
- Optimize HTML generation (
escapeHTML,renderTokens) and add large-input truncation with an appended notice.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Shared/SyntaxHighlighter.swift | Adds .log support, new token kinds/CSS, HTML rendering optimizations, and truncation/notice logic. |
| PiquePreview/Info.plist | Registers a log UTType and adds supported content types/extensions for QuickLook. |
| PiquePreview/PreviewProvider.swift | Maps log extensions to the “Log” appearance group name. |
| Pique/Info.plist | Declares the log UTType for the host app. |
| Pique/ContentView.swift | Adds a “Log” badge to the marketing/overview UI. |
| Pique/SettingsView.swift | Adds “Log” to appearance override settings. |
| PiqueTests/FileFormatTests.swift | Adds extension mapping tests for .log/.out/.err (including case-insensitivity). |
| PiqueTests/HighlightIntegrationTests.swift | Adds integration tests for log highlighting and truncation notice behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adds QuickLook preview/highlighting support for log-like plain text files and improves rendering performance for large previews across formats.
Changes:
- Introduces
.logas a supportedFileFormat(.log,.out,.err) with heuristic, line-by-line tokenization and dedicated log token kinds/CSS. - Adds preview truncation (~512k chars) with an in-preview “Preview truncated …” notice, plus rendering/escaping optimizations.
- Registers log UTIs / extensions for QuickLook and exposes “Log” in the app UI + appearance settings; adds/extends tests.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Shared/SyntaxHighlighter.swift | Adds .log support, truncation + notice insertion, and rendering/escaping perf optimizations |
| PiquePreview/Info.plist | Registers log UTI + adds supported content types/extensions for QuickLook |
| PiquePreview/PreviewProvider.swift | Maps .log/.out/.err to a user-facing “Log” format name |
| Pique/Info.plist | Declares exported UTI for log files |
| Pique/ContentView.swift | Adds “Log” to the format badge list |
| Pique/SettingsView.swift | Adds “Log” to appearance override options |
| PiqueTests/FileFormatTests.swift | Verifies .log/.out/.err mapping + case-insensitive extension handling |
| PiqueTests/HighlightIntegrationTests.swift | Adds integration tests for log highlighting + truncation behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adds QuickLook preview support for common log-file extensions with heuristic syntax highlighting, and introduces rendering optimizations to keep large-file previews responsive across formats.
Changes:
- Add
.logfile format detection (.log,.out,.err) and a heuristic, line-by-line log tokenizer with dedicated token kinds + CSS. - Improve HTML rendering performance (
escapeHTMLsingle-pass,renderTokensbuffer preallocation) and add preview truncation with an in-preview notice. - Register log UTIs / QuickLook supported types and extend UI + test coverage for the new format and truncation behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Shared/SyntaxHighlighter.swift | Adds .log highlighting, truncation logic + notice insertion, and rendering performance improvements. |
| PiquePreview/Info.plist | Declares log UTI and adds log types/extensions to QuickLook supported content. |
| PiquePreview/PreviewProvider.swift | Maps log extensions to a user-facing “Log” format name. |
| Pique/Info.plist | Declares the log UTI in the main app. |
| Pique/ContentView.swift | Adds “Log” to the format badge list. |
| Pique/SettingsView.swift | Adds “Log” to appearance override options. |
| PiqueTests/FileFormatTests.swift | Adds extension mapping tests for .log and case-insensitivity coverage. |
| PiqueTests/HighlightIntegrationTests.swift | Adds integration tests for log highlighting heuristics and truncation notice behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adds QuickLook preview support for log-like plaintext files and improves rendering performance for large previews by truncating input and optimizing HTML generation.
Changes:
- Add
.logfile format support (.log,.out,.err) with heuristic, line-by-line tokenization and new token kinds/CSS. - Add preview truncation (~512KB) with an in-preview notice and apply truncation consistently across formats.
- Optimize HTML rendering (
escapeHTMLsingle pass,renderTokensbuffered construction) and expand test coverage for log highlighting + truncation.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Shared/SyntaxHighlighter.swift | Adds .log format/tokenizer, truncation logic + notice insertion, and HTML rendering optimizations. |
| PiquePreview/Info.plist | Registers a log UTI and declares log types/extensions supported by the QuickLook extension. |
| PiquePreview/PreviewProvider.swift | Maps log extensions to the “Log” appearance group name. |
| Pique/Info.plist | Declares the log UTI for the main app bundle. |
| Pique/ContentView.swift | Adds a “Log” badge to the supported formats list. |
| Pique/SettingsView.swift | Adds “Log” to appearance override settings. |
| PiqueTests/FileFormatTests.swift | Tests extension-to-format mapping for log extensions (including case-insensitivity). |
| PiqueTests/HighlightIntegrationTests.swift | Adds integration tests for log highlighting and truncation behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Switch preview truncation from a UTF-8 byte limit to a character-based limit (previewCharLimit = 512_000), removing the UTF-8 index math and simplifying line counting. Truncation now slices by character index, appends truncation notices directly, and ensures special renderers (mobileconfig/json) receive truncated text and have the notice appended. Remove the insertTruncationNotice helper. Adjust log tokenization: simplify severity regex punctuation handling and treat 2xx HTTP status codes as .number instead of .logInfo. Update tests to match the new HTML expectations and remove several truncation-related test cases.
There was a problem hiding this comment.
Pull request overview
Adds QuickLook preview support for log-like text files and improves rendering performance for large previews by truncating and optimizing token rendering/HTML escaping.
Changes:
- Add
.log/.out/.errfile format detection and heuristic log tokenization + styling. - Improve performance via line-by-line log tokenization, faster
escapeHTML, and bufferedrenderTokens. - Add preview truncation (~500KB) with an appended “Preview truncated … lines shown” notice, plus new/updated tests and UTI declarations.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Shared/SyntaxHighlighter.swift | Adds log format + tokenizer, new token kinds/CSS, truncation, and rendering optimizations. |
| PiquePreview/Info.plist | Declares log UTI and adds log types/extensions to QuickLook supported types. |
| PiquePreview/PreviewProvider.swift | Maps log/out/err extensions to the “Log” appearance group name. |
| Pique/Info.plist | Declares the log UTI in the main app. |
| Pique/ContentView.swift | Adds “Log” to the supported-format badges shown in the app UI. |
| Pique/SettingsView.swift | Adds “Log” to appearance override settings list. |
| PiqueTests/FileFormatTests.swift | Tests extension→.log mapping and case-insensitivity for LOG. |
| PiqueTests/HighlightIntegrationTests.swift | Adds integration tests for log highlighting and truncation notice behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adds .log/.out/.err QuickLook preview support with heuristic highlighting and introduces rendering/truncation optimizations to improve performance on large files.
Changes:
- Add
FileFormat.logplus log-specific token kinds/CSS and a heuristic log tokenizer. - Add a global preview truncation mechanism (~512k chars) with a “Preview truncated…” notice.
- Register log UTIs/extensions for the app + QuickLook extension, and add UI + test coverage for logs.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
Shared/SyntaxHighlighter.swift |
Adds log format/tokenizer, new token kinds/CSS, truncation logic, and faster HTML rendering/escaping. |
PiquePreview/Info.plist |
Declares the log UTI and adds log identifiers/extensions to QuickLook supported types. |
PiquePreview/PreviewProvider.swift |
Maps .log/.out/.err to the “Log” format group name. |
Pique/Info.plist |
Declares the log UTI for the main app. |
Pique/ContentView.swift |
Adds a “Log” badge to the supported formats list. |
Pique/SettingsView.swift |
Adds “Log” to appearance override settings. |
PiqueTests/FileFormatTests.swift |
Adds extension-to-format tests for .log/.out/.err + case-insensitive mapping. |
PiqueTests/HighlightIntegrationTests.swift |
Adds integration tests for log highlighting behaviors and truncation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adds QuickLook preview support for log-like plain-text files and improves rendering performance for large inputs by optimizing HTML escaping/token rendering and introducing preview truncation.
Changes:
- Add
.logfile format support (.log,.out,.err) with heuristic, line-by-line tokenization and dedicated severity/timestamp token kinds. - Introduce truncation (~512k chars) with a “Preview truncated …” notice, plus faster
escapeHTMLandrenderTokensimplementations. - Register log UTIs/extensions in app + preview targets and extend UI/tests to recognize and validate log highlighting.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Shared/SyntaxHighlighter.swift | Adds .log format, heuristic tokenizer + CSS, truncation + perf optimizations in HTML rendering/escaping |
| PiquePreview/Info.plist | Registers log UTI and wires it into QuickLook supported types/extensions |
| PiquePreview/PreviewProvider.swift | Maps log extensions to a human-readable “Log” label |
| Pique/Info.plist | Declares the log UTI for the main app |
| Pique/ContentView.swift | Adds “Log” to the format badge list |
| Pique/SettingsView.swift | Adds “Log” to appearance override options |
| PiqueTests/FileFormatTests.swift | Tests extension mapping for .log/.out/.err and case-insensitivity |
| PiqueTests/HighlightIntegrationTests.swift | Adds integration tests for log highlighting and truncation behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Replace verbose log token classes with short names (le,lw,li,ld,lt,ln,lk,ls,lv) and update tests accordingly. Remove preview truncation and its helpers (previewCharLimit, lineCount, truncationNotice, insertHTMLFragmentBeforeBodyClose) so highlight() operates on the full source and returns special renderers early for mobileconfig/JSON/markdown. Add fast and full log HTML renderers (renderLogHTML, renderLogHTMLFast, renderLogHTMLFull) that emit direct HTML via NSRegularExpression for better performance and reduced DOM size; adjust tokenizeLog comment. Optimize escapeHTML to work at the UTF-8 byte level and update CSS color rules to include the new short classes and muted variants. These changes improve performance and HTML output size for large logs and simplify the highlighting flow; tests were adjusted to match the new class names and truncated tests were removed.
There was a problem hiding this comment.
Pull request overview
Adds QuickLook preview/highlighting support for common log file extensions and introduces rendering-path optimizations intended to improve performance on large inputs.
Changes:
- Add
.logas a supportedFileFormat(including.log,.out,.err) and map it through QuickLook + UI settings. - Implement heuristic log highlighting with a fast HTML renderer and new CSS classes for log tokens.
- Add/extend tests to cover log extension mapping and highlighting behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| Shared/SyntaxHighlighter.swift | Adds .log format handling, heuristic log highlighter, and HTML rendering optimizations. |
| PiquePreview/Info.plist | Declares/imports log UTI and registers extensions/content types for the QuickLook extension. |
| PiquePreview/PreviewProvider.swift | Maps log extensions to the “Log” appearance group label. |
| Pique/Info.plist | Declares/imports the log UTI for the main app bundle. |
| Pique/ContentView.swift | Adds “Log” to the supported-format badges shown in the app UI. |
| Pique/SettingsView.swift | Adds “Log” to appearance override settings. |
| PiqueTests/FileFormatTests.swift | Adds extension mapping tests for .log/.out/.err and case insensitivity. |
| PiqueTests/HighlightIntegrationTests.swift | Adds integration tests validating log highlighting output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var utf8 = Array(text.utf8) | ||
| var result: [UInt8] = [] | ||
| result.reserveCapacity(utf8.count + utf8.count / 8) | ||
| var runStart = 0 | ||
| for i in 0..<utf8.count { | ||
| let byte = utf8[i] | ||
| if byte == 0x26 || byte == 0x3C || byte == 0x3E || byte == 0x22 { // & < > " | ||
| // Flush preceding safe run | ||
| if i > runStart { | ||
| result.append(contentsOf: utf8[runStart..<i]) | ||
| } | ||
| switch byte { | ||
| case 0x26: result.append(contentsOf: [0x26, 0x61, 0x6D, 0x70, 0x3B]) // & | ||
| case 0x3C: result.append(contentsOf: [0x26, 0x6C, 0x74, 0x3B]) // < | ||
| case 0x3E: result.append(contentsOf: [0x26, 0x67, 0x74, 0x3B]) // > | ||
| case 0x22: result.append(contentsOf: [0x26, 0x71, 0x75, 0x6F, 0x74, 0x3B]) // " | ||
| default: break | ||
| } | ||
| runStart = i + 1 | ||
| } | ||
| } | ||
| // Flush remaining safe run | ||
| if runStart < utf8.count { | ||
| result.append(contentsOf: utf8[runStart...]) | ||
| } | ||
| return String(bytes: result, encoding: .utf8) ?? text |
| let body: String | ||
| switch format { | ||
| case .json: tokens = tokenizeJSON(source) | ||
| case .yaml: tokens = tokenizeYAML(source) | ||
| case .toml: tokens = tokenizeTOML(source) | ||
| case .xml, .mobileconfig: tokens = tokenizeXML(source) | ||
| case .shell: tokens = tokenizeShell(source) | ||
| case .powershell: tokens = tokenizePowerShell(source) | ||
| case .python: tokens = tokenizePython(source) | ||
| case .ruby: tokens = tokenizeRuby(source) | ||
| case .go: tokens = tokenizeGo(source) | ||
| case .rust: tokens = tokenizeRust(source) | ||
| case .javascript: tokens = tokenizeJavaScript(source) | ||
| case .json: body = renderTokens(tokenizeJSON(source)) | ||
| case .yaml: body = renderTokens(tokenizeYAML(source)) | ||
| case .toml: body = renderTokens(tokenizeTOML(source)) | ||
| case .xml, .mobileconfig: body = renderTokens(tokenizeXML(source)) | ||
| case .shell: body = renderTokens(tokenizeShell(source)) | ||
| case .powershell: body = renderTokens(tokenizePowerShell(source)) | ||
| case .python: body = renderTokens(tokenizePython(source)) | ||
| case .ruby: body = renderTokens(tokenizeRuby(source)) | ||
| case .go: body = renderTokens(tokenizeGo(source)) | ||
| case .rust: body = renderTokens(tokenizeRust(source)) | ||
| case .javascript: body = renderTokens(tokenizeJavaScript(source)) | ||
| case .markdown: return renderMarkdown(source, dark: darkMode) | ||
| case .hcl: tokens = tokenizeHCL(source) | ||
| case .hcl: body = renderTokens(tokenizeHCL(source)) | ||
| case .log: body = renderLogHTML(source) | ||
| } | ||
| return wrapHTML(renderTokens(tokens), dark: darkMode) | ||
|
|
||
| return wrapHTML(body, dark: darkMode) |
| private static func tokenizeLog(_ src: String) -> [Token] { | ||
| // Thin wrapper for tests that inspect Token output. | ||
| // The live rendering path uses renderLogHTML() directly. | ||
| let regex = try! Regex( |
| let allMatches = nsRegex.matches(in: src, range: NSRange(location: 0, length: totalLen)) | ||
| var cursor = 0 | ||
| for m in allMatches { |
| let allMatches = nsRegex.matches(in: src, range: NSRange(location: 0, length: totalLen)) | ||
| var cursor = 0 | ||
| for m in allMatches { |
Summary
Adds QuickLook preview support for log files (
.log,.out,.err) withheuristic-based syntax highlighting. Since log files have no consistent format,
the tokenizer uses pattern matching to colorize the most common elements that
make logs scannable at a glance.
Also speeds up rendering of large files.
What's highlighted
2025-09-16 06:20:56 +0100,Mar 28 14:05:33, Apache CLFFATAL,CRITICAL:ERROR,ERROR:WARN,WARNING:INFO,INFO:DEBUG,VERBOSE192.168.1.100GET,POST,DELETE200(green),404(orange),500(red)"disk space low"/usr/local/etc/config.yaml512MB,30s,94%Single quotes are intentionally not treated as string delimiters — apostrophes
in natural log text (
JWT's,doesn't) are far too common.Performance
Log files can be large (2MB+), so three optimizations were made:
.log— avoids O(n²) regex scanning overthe entire file by processing each line independently
escapeHTMLrewritten as a single-pass character scan (was 4 chainedreplacingOccurrencescalls, benefiting all formats)renderTokensuses a pre-allocated buffer instead ofmap+joined"⋯ Preview truncated (X of Y lines shown)" notice
Files changed (8 files, +306 −23)
Shared/SyntaxHighlighter.swift—.logformat, tokenizer, perf improvements, truncationPiquePreview/Info.plist— UTI, QLSupportedContentTypes, QLFileExtensionsPiquePreview/PreviewProvider.swift— format name mappingPique/Info.plist— UTI declarationPique/ContentView.swift— Log badgePique/SettingsView.swift— Log in appearance settingsPiqueTests/FileFormatTests.swift— extension mapping + case insensitivityPiqueTests/HighlightIntegrationTests.swift— 15 new testsTests
137 total, 0 failures. New tests cover:
JWT'snot treated as string).LOG)